package com.example.demo.test1.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.exception.BaseServiceException;
import com.example.demo.io.bio.Test;
import com.example.demo.test1.entity.Account;
import com.example.demo.test1.entity.Test1;
import com.example.demo.test1.mapper.AccountMapper;
import com.example.demo.test1.mapper.ITest1Mapper;
import com.example.demo.test1.service.ITest1Service;
import com.example.demo.utils.CollectionUtil;
import com.example.demo.utils.KeyValue;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;

@Service
public class Test1ServiceImpl extends ServiceImpl<ITest1Mapper, Test1> implements ITest1Service {

    @Autowired
    private ITest1Mapper test1Mapper;
    @Autowired
    private Test1ServiceImpl test1Service;
    @Autowired
    private AccountMapper accountMapper;

    @Override
    public Page<Test1> getList(Page<Test1> page) {
        return page.setRecords(test1Mapper.getList(page));
    }

    @Override
    public void rock(String fileName) {
        try {
            test1Service.doSave(fileName);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Transactional
    public void doSave(String fileName) {
        Test1 test1 = new Test1();
        test1.setFirst(fileName);
        test1.setSecond("222");
        test1.setCreateTime(new Date());
        save(test1);
        if (StringUtils.isEmpty(fileName)){
            throw new RuntimeException("aaa");
        }
    }
}
